<?php
			print "<div id=\"cropName\">Displaying results for <b>$cropNames[0]</b> for dates: ".$_GET['date1']." - ".$_GET['date2'].":</div>";
			foreach ($attrs as $a) {
				if ($a == "sales") {
					$result = $result . "<th>".attributeFormat($a)." (".$_GET['customers'].")</th>";
				}
				else if ($a == "amount_donated") {
					$result = $result . "<th>".attributeFormat($a)." (".$_GET['donationCustomers'].")</th>";
				}
				else {
					$result = $result . "<th>$a</th>";
				}
			}
			$result = $result . "</tr></thead><tbody>";
			
			$startMonthNum = substr($startDate,5,2); //gets start month number
			$endMonthNum = substr($endDate,5,2);
			
			for ($l = $startMonthNum; $l <= $endMonthNum; $l++) {
				$result = $result . "<tr><td><img id=\"".getMonth($l)."\" src=\"DataTables-1.7.3/details_open.png\" /></td><td>".getMonth($l)." $startYear</td>";
				foreach ($attrs as $a) {
					if ($l < 10 && substr($l,0,1) != '0') {
						if ($a == "sales") {
							$data = getMultiYearCropData($startYear."-0".$l."-01", $startYear."-0".$l."-31", $crops[0], $a, getUnitId($units[0]), getCustomerId($_GET['customers']));
						}
						else if ($a == "amount_donated") {
							$data = getMultiYearCropData($startYear."-0".$l."-01", $startYear."-0".$l."-31", $crops[0], $a, getUnitId($units[0]), getCustomerId($_GET['donationCustomers']));
						}
						else if ($a == "amount_harvested") {
							$data = getMultiYearCropData($startYear."-0".$l."-01", $startYear."-0".$l."-31", $crops[0], $a, getUnitId($units[0]));
						}
						else {
							$data = getMultiYearCropData($startYear."-0".$l."-01", $startYear."-0".$l."-31", $crops[0], $a);
						}
					}
					else { // gets rid of a zero in that year that may or may not cause problems in the functions (the SQL calls should be ok, but functions may need a certain format, not sure tho
						if ($a == "sales") {
							$data = getMultiYearCropData($startYear."-".$l."-01", $startYear."-".$l."-31", $crops[0], $a, getUnitId($units[0]), getCustomerId($_GET['customers']));
						}
						else if ($a == "amount_donated") {
							$data = getMultiYearCropData($startYear."-".$l."-01", $startYear."-".$l."-31", $crops[0], $a, getUnitId($units[0]), getCustomerId($_GET['donationCustomers']));
						}
						else if ($a == "amount_harvested") {
							$data = getMultiYearCropData($startYear."-".$l."-01", $startYear."-".$l."-31", $crops[0], $a, getUnitId($units[0]));
						}
						else {
							$data = getMultiYearCropData($startYear."-".$l."-01", $startYear."-".$l."-31", $crops[0], $a);
						}
					}
					//$result = $result . "</tr>";
					//$result = $result . "<tr><td><img src=\"DataTables-1.7.3/details_open.png\" /></td><td>".getMonth($l)."</td>";
					foreach ($data as $year => $d) { //should only be one element in the array, just cracking it open
						$result = $result . "<td>".$d."</td>";
						break; //loop should only happen once anyway, even without this break, just making sure
					}
					if (count($data) == 0) {
						$result = $result . "<td></td>";
					}
				}
				$result = $result . "</tr>";
			}
?>